package scyComposition

import (
	"github.com/gin-gonic/gin"
	"likeadmin/clog"
	"likeadmin/dbc"
	"likeadmin/model"
	"likeadmin/sqlop"
	"likeadmin/webu"
	"time"
)

func CreateScyComposition(c *gin.Context) {
	scyComposition := &model.ScyComposition{}
	c.ShouldBind(scyComposition)
	scyComposition.CreateTime = time.Now().Unix()
	clog.Info("scyComposition,CreateScyComposition,scyComposition=", scyComposition)
	err := dbc.DB.Create(scyComposition).Error
	webu.GinResult("CreateScyComposition Error:", c, err)
}

func UpdateScyComposition(c *gin.Context) {
	scyComposition := &model.ScyComposition{}
	c.ShouldBind(scyComposition)
	clog.Info("scyComposition,UpdateScyComposition,scyComposition=", scyComposition)
	err := sqlop.ExecThreeP("update scy_composition set composition_name=?,update_time=? where id=?", scyComposition.CompositionName, time.Now().Unix(), scyComposition.Id)
	webu.GinResult("UpdateScyComposition Error:", c, err)

}

func DeleteScyComposition(c *gin.Context) {
	scyComposition := &model.ScyComposition{}
	c.ShouldBind(scyComposition)
	clog.Info("scyComposition,DeleteScyComposition,scyComposition=", scyComposition)
	err := sqlop.ExecTwoP("update scy_composition set is_deleted=1,delete_time=? where id=?", time.Now().Unix(), scyComposition.Id)
	webu.GinResult("DeleteScyComposition Error:", c, err)
}
